﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace Coding4Fun.BoxingBots.Boxer.Controls
{
	/// <summary>
	/// Interaction logic for BoxerThumbStick.xaml
	/// </summary>
	public partial class BoxerThumbStick : UserControl
	{
		public BoxerThumbStick()
		{
			InitializeComponent();

			DataContext = this;
		}

		public event EventHandler<RoutedPropertyChangedEventArgs<double>> DeadzoneChanged;

		private void BoxerVectorDeadzone_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			AllowedMovementArea = e.NewValue;

			if (DeadzoneChanged != null)
				DeadzoneChanged.Invoke(sender, e);
		}

		public string Title
		{
			get { return (string)GetValue(TitleProperty); }
			set { SetValue(TitleProperty, value); }
		}

		// Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty TitleProperty =
			DependencyProperty.Register("Title", typeof(string), typeof(BoxerThumbStick), new UIPropertyMetadata("Boxer"));



		public double AllowedMovementArea
		{
			get { return (double)GetValue(AllowedMovementAreaProperty); }
			set { SetValue(AllowedMovementAreaProperty, value); }
		}

		// Using a DependencyProperty as the backing store for AllowedMovementArea.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty AllowedMovementAreaProperty =
			DependencyProperty.Register("AllowedMovementArea", typeof(double), typeof(BoxerThumbStick), new UIPropertyMetadata(0d));

		public double HorizontalValue
		{
			get { return (double)GetValue(HorizontalValueProperty); }
			set { SetValue(HorizontalValueProperty, value); }
		}

		// Using a DependencyProperty as the backing store for HorizontalValue.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty HorizontalValueProperty =
			DependencyProperty.Register("HorizontalValue", typeof(double), typeof(BoxerThumbStick), new UIPropertyMetadata(0.0));

		public double VerticalValue
		{
			get { return (double)GetValue(VerticalValueProperty); }
			set { SetValue(VerticalValueProperty, value); }
		}

		// Using a DependencyProperty as the backing store for VerticalValue.  This enables animation, styling, binding, etc...
		public static readonly DependencyProperty VerticalValueProperty =
			DependencyProperty.Register("VerticalValue", typeof(double), typeof(BoxerThumbStick), new UIPropertyMetadata(0.0));
	}
}
